﻿using CPPEI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CMS.Domain.Services
{
    public class GetService
    {
        public SingleResult<Entities.EArticle> GetArticle(Guid id)
        {
            using (CMSDbContext dbContext = new CMSDbContext())
            {
                EntityRepository<Entities.EArticle> rep = new EntityRepository<Entities.EArticle>(dbContext);

                Entities.EArticle article = rep.Get(p => p.Id == id);

                if(article != null)
                {
                    return new SingleResult<Entities.EArticle>(article);
                }
                else
                {
                    return new SingleResult<Entities.EArticle>(0);
                }
            }
        }
    }
}
